<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../include/tag.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>${empty signGroup.id ? '创建' : '编辑'}队伍</title>
    <%@include file="../include/commonFile.jsp"%>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/ui/activity/publish_form.css">

</head><body>
<!--头部-->
<%@include file="../include/header.jsp"%>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp"%>
    <!--内容-->
    <section>
        <div class="section-main">
            <!-- 正文请写在这里 -->
            <div class="add-form-content">
            <form id="myForm" class="layui-form mt20" method="post" action="${ctx}/sign/group/save.do">
                <input type="hidden" name="id" value="${signGroup.id}" />
                <input type="hidden" name="projectId" value="${signGroup.projectId}" />
                <div class="layui-form-item">
                    <label class="layui-form-label">队伍名称<span class="f-verify-red">*</span></label>
                    <div class="layui-input-block">
                        <input type="text" style="width: 85%" name="name" lay-verify="name" autocomplete="off" class="layui-input" value="${signGroup.name}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">队伍备注</label>
                    <div class="layui-input-block">
                        <textarea name="remarks" placeholder="队伍备注" lay-verify="remarks" class="layui-textarea" style="width: 85%" >${signGroup.remarks}</textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <a href="javascript:void(0)" class="layui-btn layui-btn-danger" lay-submit lay-filter="*">立即提交</a>
                        <a href="${ctx}/sign/group/list.do?projectId=${signGroup.projectId}" class="layui-btn layui-btn-primary">取消</a>
                    </div>
                </div>
            </form>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp"%>
    </section>
</div>

<script>

    $(function () {
        layui.use([ 'form', 'laydate' ], function() {
            var form = layui.form;

            //自定义验证规则
            form.verify({
                name : function(value) {
                    if (value == "") {
                        return '请填写队伍名称';
                    }
                }
            });

            //监听提交
            form.on('submit', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    $.post('${ctx}/sign/group/save.do', $('#myForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess("提交成功", function () {
                                location.href = "${ctx}/sign/group/list.do?projectId=${signGroup.projectId}";
                            });
                        } else {
                            util.layerMsgError(res.description)
                        }
                    });
                }, '${signGroup.id}');
                return false;
            });
            form.render('radio');
        });
    })

</script>
<c:if test="${empty signGroup.id}">
    <script type="text/javascript">
        txz.initHeader({
            nav: [{
                name: '我发布的打卡项目',
                href: '${ctx}/sign/project/list.do'
            }, {
                name: '${signProject.title}',
                href: '${ctx}/sign/project/list.do'
            }, {
                name: '队伍管理'
            }, {
                name: '创建队伍',
                curr: true
            }],
            btns: [{
                name: '返回',
                icon: 'back',
                href: '${ctx}/sign/group/list.do?projectId=${signGroup.projectId}'
            }]
        });
    </script>
</c:if>
<c:if test="${not empty signGroup.id}">
    <script type="text/javascript">
        txz.initHeader({
            nav:[{
                name: '我发布的打卡项目',
                href: '${ctx}/sign/project/list.do'
            }, {
                name: '${signProject.title}',
                href: '${ctx}/sign/project/list.do'
            }, {
                name: '队伍管理'
            },{
                name: '编辑队伍',
                curr: true
            }],
            btns:[{
                name: '返回',
                icon: 'back',
                href: '${ctx}/sign/group/list.do?projectId=${signGroup.projectId}'
            }]
        });
    </script>
</c:if>
</body>
</html>